package mars.activity;

import java.io.StringReader;

import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import bear.download.Circlenaread;
import bear.download.Friendsread;
import bear.download.HttpsUtils;
import android.app.Activity;  
import android.content.Intent;
import android.os.Bundle;  
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import android.view.View;

public class friendActivity extends Activity {  
	private Button first_btn1,first_btn2,first_btn3,first_btn4,first_btn5,first_btn6,first_btn7,first_btn8,first_btn9;
	private Button turnup3,turndown3;
	private TextView pages3;   
	    /** Called when the activity is first created. */  
	    @Override  
	    public void onCreate(Bundle savedInstanceState) {  
	        super.onCreate(savedInstanceState);  
	        setContentView(R.layout.friend); 
	        	        
	        first_btn1 = (Button) findViewById(R.id.first_btn1);   
	        first_btn2 = (Button) findViewById(R.id.first_btn2);        
	        first_btn3 = (Button) findViewById(R.id.first_btn3);     
	        first_btn4 = (Button) findViewById(R.id.first_btn4);          
	        first_btn5 = (Button) findViewById(R.id.first_btn5);      
	        first_btn6 = (Button) findViewById(R.id.first_btn6);        
	        first_btn7 = (Button) findViewById(R.id.first_btn7);        
	        first_btn8 = (Button) findViewById(R.id.first_btn8);  	        
	        first_btn9 = (Button) findViewById(R.id.first_btn9);
	        
	        String name[]=Friendsread.name1.split("\\$");
	        String count[]=Friendsread.count1.split("\\$");
	        String category[]=Friendsread.category1.split("\\$");
	        if(Friendsread.n==1){
	        first_btn1.setText(name[0]+category[0]+count[0]);
    				first_btn1.setVisibility(View.VISIBLE);
	        }
	        if(Friendsread.n==2){
	        first_btn1.setText(name[0]+category[0]+count[0]);
					first_btn1.setVisibility(View.VISIBLE);
					first_btn2.setText(name[1]+category[1]+count[1]);
					first_btn2.setVisibility(View.VISIBLE);
	        }
	        if(Friendsread.n==3){
	        first_btn1.setText(name[0]+category[0]+count[0]);
			first_btn1.setVisibility(View.VISIBLE);
			first_btn2.setText(name[1]+category[1]+count[1]);
			first_btn2.setVisibility(View.VISIBLE);
			first_btn3.setText(name[2]+category[2]+count[2]);
			first_btn3.setVisibility(View.VISIBLE);
	        }
	        if(Friendsread.n==4){
	        first_btn1.setText(name[0]+category[0]+count[0]);
			first_btn1.setVisibility(View.VISIBLE);
			first_btn2.setText(name[1]+category[1]+count[1]);
			first_btn2.setVisibility(View.VISIBLE);
			first_btn3.setText(name[2]+category[2]+count[2]);
			first_btn3.setVisibility(View.VISIBLE);
			first_btn4.setText(name[3]+category[3]+count[3]);
			first_btn4.setVisibility(View.VISIBLE);
	        }
	        if(Friendsread.n==5){
	        first_btn1.setText(name[0]+category[0]+count[0]);
			first_btn1.setVisibility(View.VISIBLE);
			first_btn2.setText(name[1]+category[1]+count[1]);
			first_btn2.setVisibility(View.VISIBLE);
			first_btn3.setText(name[2]+category[2]+count[2]);
			first_btn3.setVisibility(View.VISIBLE);
			first_btn4.setText(name[3]+category[3]+count[3]);
			first_btn4.setVisibility(View.VISIBLE);
			first_btn5.setText(name[4]+category[4]+count[4]);
			first_btn5.setVisibility(View.VISIBLE);
	        }
	        if(Friendsread.n==6){
		        first_btn1.setText(name[0]+category[0]+count[0]);
				first_btn1.setVisibility(View.VISIBLE);
				first_btn2.setText(name[1]+category[1]+count[1]);
				first_btn2.setVisibility(View.VISIBLE);
				first_btn3.setText(name[2]+category[2]+count[2]);
				first_btn3.setVisibility(View.VISIBLE);
				first_btn4.setText(name[3]+category[3]+count[3]);
				first_btn4.setVisibility(View.VISIBLE);
				first_btn5.setText(name[4]+category[4]+count[4]);
				first_btn5.setVisibility(View.VISIBLE);
				first_btn6.setText(name[5]+category[5]+count[5]);
				first_btn6.setVisibility(View.VISIBLE);
		        }
	        if(Friendsread.n==7){
		        first_btn1.setText(name[0]+category[0]+count[0]);
				first_btn1.setVisibility(View.VISIBLE);
				first_btn2.setText(name[1]+category[1]+count[1]);
				first_btn2.setVisibility(View.VISIBLE);
				first_btn3.setText(name[2]+category[2]+count[2]);
				first_btn3.setVisibility(View.VISIBLE);
				first_btn4.setText(name[3]+category[3]+count[3]);
				first_btn4.setVisibility(View.VISIBLE);
				first_btn5.setText(name[4]+category[4]+count[4]);
				first_btn5.setVisibility(View.VISIBLE);
				first_btn6.setText(name[5]+category[5]+count[5]);
				first_btn6.setVisibility(View.VISIBLE);
				first_btn7.setText(name[6]+category[6]+count[6]);
				first_btn7.setVisibility(View.VISIBLE);
		        }
	        if(Friendsread.n==8){
		        first_btn1.setText(name[0]+category[0]+count[0]);
				first_btn1.setVisibility(View.VISIBLE);
				first_btn2.setText(name[1]+category[1]+count[1]);
				first_btn2.setVisibility(View.VISIBLE);
				first_btn3.setText(name[2]+category[2]+count[2]);
				first_btn3.setVisibility(View.VISIBLE);
				first_btn4.setText(name[3]+category[3]+count[3]);
				first_btn4.setVisibility(View.VISIBLE);
				first_btn5.setText(name[4]+category[4]+count[4]);
				first_btn5.setVisibility(View.VISIBLE);
				first_btn6.setText(name[5]+category[5]+count[5]);
				first_btn6.setVisibility(View.VISIBLE);
				first_btn7.setText(name[6]+category[6]+count[6]);
				first_btn7.setVisibility(View.VISIBLE);
				first_btn8.setText(name[7]+category[7]+count[7]);
				first_btn8.setVisibility(View.VISIBLE);
		        }
	        if(Friendsread.n==9){
		        first_btn1.setText(name[0]+category[0]+count[0]);
				first_btn1.setVisibility(View.VISIBLE);
				first_btn2.setText(name[1]+category[1]+count[1]);
				first_btn2.setVisibility(View.VISIBLE);
				first_btn3.setText(name[2]+category[2]+count[2]);
				first_btn3.setVisibility(View.VISIBLE);
				first_btn4.setText(name[3]+category[3]+count[3]);
				first_btn4.setVisibility(View.VISIBLE);
				first_btn5.setText(name[4]+category[4]+count[4]);
				first_btn5.setVisibility(View.VISIBLE);
				first_btn6.setText(name[5]+category[5]+count[5]);
				first_btn6.setVisibility(View.VISIBLE);
				first_btn7.setText(name[6]+category[6]+count[6]);
				first_btn7.setVisibility(View.VISIBLE);
				first_btn8.setText(name[7]+category[7]+count[7]);
				first_btn8.setVisibility(View.VISIBLE);
				first_btn9.setText(name[8]+category[8]+count[8]);
				first_btn9.setVisibility(View.VISIBLE);
		        }
	        
	        pages3=(TextView)findViewById(R.id.pages3);
	        turnup3=(Button)findViewById(R.id.turnup3);
	        turndown3=(Button)findViewById(R.id.turndown3);
	        pages3.setText("1/1");
	        turndown3.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					Toast.makeText(friendActivity.this, R.string.down0,Toast.LENGTH_LONG).show();
				}	
	        });
	        turnup3.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					Toast.makeText(friendActivity.this, R.string.up0,Toast.LENGTH_LONG).show();
				}	
	        });
	        first_btn3.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					String lsids[]=Friendsread.lsid1.split("\\$");
					HttpsUtils jing=new HttpsUtils();
					String circle2Url=jing.get("https://www.loushiapp.com/?c=say&a=getsay&hash="+landActivity.hash+"&lsid="+lsids[2]);
					try{
						SAXParserFactory cu1 = SAXParserFactory.newInstance();
						XMLReader reader=cu1.newSAXParser().getXMLReader();
						reader.setContentHandler(new Circlenaread());
						reader.parse(new InputSource(new StringReader(circle2Url)));
					}catch(Exception e){
						e.printStackTrace();
					}
					Intent inye9=new Intent();
					inye9.setClass(friendActivity.this, TestFilp.class);
					friendActivity.this.startActivity(inye9);
					finish();
				}	
	        });
	        first_btn2.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					String lsids[]=Friendsread.lsid1.split("\\$");
					HttpsUtils jing=new HttpsUtils();
					String circle2Url=jing.get("https://www.loushiapp.com/?c=say&a=getsay&hash="+landActivity.hash+"&lsid="+lsids[1]);
					try{
						SAXParserFactory cu2 = SAXParserFactory.newInstance();
						XMLReader reader=cu2.newSAXParser().getXMLReader();
						reader.setContentHandler(new Circlenaread());
						reader.parse(new InputSource(new StringReader(circle2Url)));
					}catch(Exception e){
						e.printStackTrace();
					}
					Intent inye8=new Intent();
					inye8.setClass(friendActivity.this, TestFilp.class);
					friendActivity.this.startActivity(inye8);
					finish();
				}	
	        });
	        first_btn1.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					String lsids[]=Friendsread.lsid1.split("\\$");
					HttpsUtils jing=new HttpsUtils();
					String circle2Url=jing.get("https://www.loushiapp.com/?c=say&a=getsay&hash="+landActivity.hash+"&lsid="+lsids[0]);
					try{
						SAXParserFactory cu3 = SAXParserFactory.newInstance();
						XMLReader reader=cu3.newSAXParser().getXMLReader();
						reader.setContentHandler(new Circlenaread());
						reader.parse(new InputSource(new StringReader(circle2Url)));
					}catch(Exception e){
						e.printStackTrace();
					}
					Intent inye1=new Intent();
					inye1.setClass(friendActivity.this, TestFilp.class);
					friendActivity.this.startActivity(inye1);
					finish();
				}	
	        });
	        first_btn4.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					String lsids[]=Friendsread.lsid1.split("\\$");
					HttpsUtils jing=new HttpsUtils();
					String circle2Url=jing.get("https://www.loushiapp.com/?c=say&a=getsay&hash="+landActivity.hash+"&lsid="+lsids[3]);
					try{
						SAXParserFactory cu4 = SAXParserFactory.newInstance();
						XMLReader reader=cu4.newSAXParser().getXMLReader();
						reader.setContentHandler(new Circlenaread());
						reader.parse(new InputSource(new StringReader(circle2Url)));
					}catch(Exception e){
						e.printStackTrace();
					}
					Intent inye2=new Intent();
					inye2.setClass(friendActivity.this, TestFilp.class);
					friendActivity.this.startActivity(inye2);
					finish();
				}	
	        });
	        first_btn5.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					String lsids[]=Friendsread.lsid1.split("\\$");
					HttpsUtils jing=new HttpsUtils();
					String circle2Url=jing.get("https://www.loushiapp.com/?c=say&a=getsay&hash="+landActivity.hash+"&lsid="+lsids[4]);
					try{
						SAXParserFactory cu5 = SAXParserFactory.newInstance();
						XMLReader reader=cu5.newSAXParser().getXMLReader();
						reader.setContentHandler(new Circlenaread());
						reader.parse(new InputSource(new StringReader(circle2Url)));
					}catch(Exception e){
						e.printStackTrace();
					}
					Intent inye3=new Intent();
					inye3.setClass(friendActivity.this, TestFilp.class);
					friendActivity.this.startActivity(inye3);
					finish();
				}	
	        });
	        first_btn6.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					String lsids[]=Friendsread.lsid1.split("\\$");
					HttpsUtils jing=new HttpsUtils();
					String circle2Url=jing.get("https://www.loushiapp.com/?c=say&a=getsay&hash="+landActivity.hash+"&lsid="+lsids[5]);
					try{
						SAXParserFactory cu6 = SAXParserFactory.newInstance();
						XMLReader reader=cu6.newSAXParser().getXMLReader();
						reader.setContentHandler(new Circlenaread());
						reader.parse(new InputSource(new StringReader(circle2Url)));
					}catch(Exception e){
						e.printStackTrace();
					}
					Intent inye4=new Intent();
					inye4.setClass(friendActivity.this, TestFilp.class);
					friendActivity.this.startActivity(inye4);
					finish();
				}	
	        });
	        first_btn7.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					String lsids[]=Friendsread.lsid1.split("\\$");
					HttpsUtils jing=new HttpsUtils();
					String circle2Url=jing.get("https://www.loushiapp.com/?c=say&a=getsay&hash="+landActivity.hash+"&lsid="+lsids[6]);
					try{
						SAXParserFactory cu7 = SAXParserFactory.newInstance();
						XMLReader reader=cu7.newSAXParser().getXMLReader();
						reader.setContentHandler(new Circlenaread());
						reader.parse(new InputSource(new StringReader(circle2Url)));
					}catch(Exception e){
						e.printStackTrace();
					}
					Intent inye5=new Intent();
					inye5.setClass(friendActivity.this, TestFilp.class);
					friendActivity.this.startActivity(inye5);
					finish();
				}	
	        });
	        first_btn8.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					String lsids[]=Friendsread.lsid1.split("\\$");
					HttpsUtils jing=new HttpsUtils();
					String circle2Url=jing.get("https://www.loushiapp.com/?c=say&a=getsay&hash="+landActivity.hash+"&lsid="+lsids[7]);
					try{
						SAXParserFactory cu8 = SAXParserFactory.newInstance();
						XMLReader reader=cu8.newSAXParser().getXMLReader();
						reader.setContentHandler(new Circlenaread());
						reader.parse(new InputSource(new StringReader(circle2Url)));
					}catch(Exception e){
						e.printStackTrace();
					}
					Intent inye6=new Intent();
					inye6.setClass(friendActivity.this, TestFilp.class);
					friendActivity.this.startActivity(inye6);
					finish();
				}	
	        });
	        first_btn9.setOnClickListener(new Button.OnClickListener()
	        {
				public void onClick(View v) {
					// TODO Auto-generated method stub;
					String lsids[]=Friendsread.lsid1.split("\\$");
					HttpsUtils jing=new HttpsUtils();
					String circle2Url=jing.get("https://www.loushiapp.com/?c=say&a=getsay&hash="+landActivity.hash+"&lsid="+lsids[8]);
					try{
						SAXParserFactory cu9 = SAXParserFactory.newInstance();
						XMLReader reader=cu9.newSAXParser().getXMLReader();
						reader.setContentHandler(new Circlenaread());
						reader.parse(new InputSource(new StringReader(circle2Url)));
					}catch(Exception e){
						e.printStackTrace();
					}
					Intent inye7=new Intent();
					inye7.setClass(friendActivity.this, TestFilp.class);
					friendActivity.this.startActivity(inye7);
					finish();
				}	
	        });
	    }     	  
	}   
